﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AutomatedTP
{
    /// <summary>
    /// In this class is stored information about testing subprocedure.
    /// </summary>
    public class Tproc : Func
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="Tproc"/> class.
        /// local variables - will be generated if needed but not stored here!
        /// </summary>
        public Tproc() : base("tproc")
        {  
        }        
        
        //input parameters = have to has same name in XML source
        private List<Variable> in_params = new List<Variable>();

        //init of global variables + output init
        private List<Variable>  init_glob_variables = new List<Variable>();

        //expected output for global variables
        private List<Variable> exp_glob_variables = new List<Variable>();
        private Variable exp_ret;
        
        //testing preconditions

        //tested function
        public string tested_func { set; get; }

        //calling sequence !!!
        private Dictionary<string, int> sequence = new Dictionary<string, int>();

        //defined order || free order => instance?      
        public bool defined_order { set; get; }

        /// <summary>
        /// Gets the calling sequence.
        /// </summary>
        /// <returns></returns>
        public Dictionary<string, int> GetSequence()
        {
            return sequence;
        }

        /// <summary>
        /// Gets the input parameter.
        /// </summary>
        /// <returns></returns>
        public List<Variable> GetInPar()
        {
            return in_params;
        }

        /// <summary>
        /// Gets the return value.
        /// </summary>
        /// <returns></returns>
        public Variable GetRetVal()
        {
            return exp_ret;
        }

        /// <summary>
        /// Gets the initialize global variables.
        /// </summary>
        /// <returns></returns>
        public List<Variable> GetInitGlobVar()
        {
            return init_glob_variables;
        }

        /// <summary>
        /// Gets the expected global variables.
        /// </summary>
        /// <returns></returns>
        public List<Variable> GetExpGlobVar()
        {
            return exp_glob_variables;
        }

        /// <summary>
        /// Adds the call.
        /// </summary>
        /// <param name="name">The name of function to be called.</param>
        /// <param name="times">The times.</param>
        public void AddCall(string name, int times)
        {
            sequence.Add(name, times);
        }

        /// <summary>
        /// Adds the input parameter.
        /// </summary>
        /// <param name="var">The variable.</param>
        public void AddInPar(Variable var)
        {
            in_params.Add(var);
        }

        /// <summary>
        /// Adds the initialize global variable.
        /// </summary>
        /// <param name="var">The variable.</param>
        public void AddInitGlobVar(Variable var)
        {
            init_glob_variables.Add(var);
        }

        /// <summary>
        /// Adds the expected global variable.
        /// </summary>
        /// <param name="var">The variable.</param>
        public void AddExpGlobVar(Variable var)
        {
            exp_glob_variables.Add(var);
        }

        /// <summary>
        /// Sets the return value.
        /// </summary>
        /// <param name="var">The variable.</param>
        public void SetRetVal(Variable var)
        {
            exp_ret = var;
        }
    }
}
